import {
  exportUrl,
  getLineCodeList,
  getProdOrderStatusList,
  getProdOrderTypeList,
  getPrepositionTypeList,
  getBackflushTypeList,
  getSimulatedTypeList,
} from "@/api/print/mesProdOrder";
// 列表头按钮配置
export const operateList = [
  // {
  //   name: $i18n.t("printBoxCode.create"),
  //   type: "primary",
  //   icon: "el-icon-printer",
  //   handleName: "getGenCount", // 点击时返回的标识
  //   // 只能选择一条
  //   isSingle: true,
  //   // 是否可点击；
  //   disabled: (data) => {
  //     return data.length !== 1;
  //   },
  // },
  {
    name: $i18n.t("mesUniqueCodePrinting.printUniqueCode"),
    type: "primary",
    icon: "el-icon-printer",
    handleName: "printBoxCode", // 点击时返回的标识
    isSingle: true, //至少选择一条
    //是否可点击；
    disabled: (data) => {
      return data.length != 1;
    },
  },
  {
    name: $i18n.t("mesUniqueCodePrinting.clearUniqueCode"),
    type: "danger",
    icon: "el-icon-printer",
    handleName: "clearBarcode", // 点击时返回的标识
    // 只能选择一条
    isSingle: true,
    // 是否可点击；
    disabled: (data) => {
      return data.length !== 1;
    },
  },
  {
    name: $i18n.t("mesUniqueCodePrinting.reprint"),
    type: "primary",
    icon: "el-icon-brush",
    handleName: "repairPrint", // 点击时返回的标识
    isSingle: true, //至少选择一条
    auth: "mes:uniqueCode:reprint",
    //是否可点击；
    disabled: (data) => {
      return data.length != 1;
    },
  },
];
// 行末按钮配置
export const rowConfig = [
  {
    name: $i18n.t("common.show"),
    type: "primary",
    class: "row-btn-primary",
    handleName: "show", //点击时返回的标识
  },
];
// 搜索条件配置
export const searchConfig = {
  data() {
    const self = this;
    return {
      searchDialog: {
        inline: true,
        formDesc: {
          orderCode: {
            type: "input",
            label: $i18n.t("mesUniqueCodePrinting.orderCode"),
          },
          prodCode: {
            type: "input",
            label: $i18n.t("mesUniqueCodePrinting.prodCode"),
          },
          prodOrderType: {
            label: $i18n.t("mesUniqueCodePrinting.prodOrderType"),
            type: "select",
            prop: {
              value: "value",
              text: "description",
            },
            options: async (data) => {
              const list = await getProdOrderTypeList();
              return list.data.result;
            },
          },
          planBeginDate: {
            type: "daterange",
            label: $i18n.t("mesUniqueCodePrinting.planBeginDate"),
            attrs: {
              valueFormat: "yyyy-MM-dd",
              searchArrKey: ["planBeginDateMin", "planBeginDateMax"],
            },
          },
          lineCode: {
            label: $i18n.t("common.line"),
            type: "select",
            prop: {
              value: "modelingCode",
              text: "modelingName",
            },
            options: async (data) => {
              const params = {
                modelingCode: self.$store.getters.factoryCode,
                level: 5,
              };
              const list = await getLineCodeList(params);
              return list.data.result;
            },
          },
          orderStatus: {
            label: $i18n.t("mesUniqueCodePrinting.orderStatus"),
            type: "select",

            prop: {
              value: "value",
              text: "description",
            },
            options: async (data) => {
              const list = await getProdOrderStatusList();
              return list.data.result;
            },
          },
        },
      },
    };
  },
};
// 新增/删除表单配置
export const formDescDialog = {
  span: 24,
  disabled: true,
  isShowSubmitBtn: false,
  formDesc: {
    orderCode: {
      type: "input",
      label: $i18n.t("mesUniqueCodePrinting.orderCode"),
      layout: 8,
      // disabled: (d) => !!d.id,
      disabled: (data) => {
        return !!data.codeStrategy || !!data.id;
      },
      // required: true,
    },
    planCode: {
      type: "select",
      label: $i18n.t("mesUniqueCodePrinting.planCode"),
      layout: 8,
      required: true,
    },

    prodCode: {
      type: "input",
      label: $i18n.t("mesUniqueCodePrinting.prodCode"),
      layout: 8,
      required: true,
    },

    prodName: {
      type: "input",
      label: $i18n.t("mesUniqueCodePrinting.prodName"),
      layout: 8,
      required: false,
      disabled: true,
    },
    seriesCode: {
      type: "input",
      label: $i18n.t("mesUniqueCodePrinting.seriesCode"),
      layout: 8,
      required: true,
      disabled: true,
    },

    seriesName: {
      type: "input",
      label: $i18n.t("mesUniqueCodePrinting.seriesName"),
      layout: 8,
      disabled: true,
    },
    unit: {
      type: "input",
      label: $i18n.t("mesUniqueCodePrinting.measureUnit"),
      layout: 8,
      disabled: true,
    },
    bomVersionNumber: {
      type: "input",
      label: $i18n.t("mesUniqueCodePrinting.bomVersionNumber"),
      layout: 8,
      required: false,
    },
    simulatedType: {
      type: "select",
      label: $i18n.t("mesUniqueCodePrinting.simulatedType"),
      layout: 8,
      required: true,
      prop: {
        value: "value",
        text: "description",
      },
      options: async (data) => {
        const list = await getSimulatedTypeList();
        return list.data.result;
      },
    },
    prodOrderType: {
      type: "select",
      label: $i18n.t("mesUniqueCodePrinting.prodOrderType"),
      layout: 8,
      required: true,
      prop: {
        value: "value",
        text: "description",
      },
      options: async (data) => {
        const list = await getProdOrderTypeList();
        return list.data.result;
      },
    },
    deliveryDate: {
      type: "date",
      label: $i18n.t("mesUniqueCodePrinting.deliveryDate"),
      layout: 8,
      required: false,
      attrs: {
        valueFormat: "yyyy-MM-dd",
      },
    },
    slackTime: {
      type: "number",
      label: $i18n.t("mesUniqueCodePrinting.slackTime"),
      layout: 8,
      required: false,
    },
    quantity: {
      type: "number",
      label: $i18n.t("mesUniqueCodePrinting.planQuantity"),
      layout: 8,
      required: true,
    },

    planBeginDate: {
      type: "date",
      label: $i18n.t("mesUniqueCodePrinting.planBeginDate"),
      layout: 8,
      required: true,
      attrs: {
        valueFormat: "yyyy-MM-dd",
      },
    },
    planEndDate: {
      type: "date",
      label: $i18n.t("mesUniqueCodePrinting.planEndDate"),
      layout: 8,
      required: true,
      attrs: {
        valueFormat: "yyyy-MM-dd",
      },
    },
    backflushType: {
      type: "select",
      label: $i18n.t("mesUniqueCodePrinting.backFlushType"),
      layout: 8,
      required: true,
      prop: {
        value: "value",
        text: "description",
      },
      options: async (data) => {
        const list = await getBackflushTypeList();
        return list.data.result;
      },
    },
    prepositionCode: {
      type: "input",
      label: $i18n.t("mesUniqueCodePrinting.prepositionCode"),
      layout: 8,
      // required: true,
    },
    prepositionType: {
      type: "select",
      label: $i18n.t("mesUniqueCodePrinting.prepositionType"),
      layout: 8,
      // required: true,
      prop: {
        value: "value",
        text: "description",
      },
      options: async (data) => {
        const list = await getPrepositionTypeList();
        return list.data.result;
      },
    },
    remark: {
      type: "input",
      label: $i18n.t("common.remark"),
      layout: 24,
      required: false,
    },
  },
};
